package inits

import (
	"2212b/2212ay1/global"
	"context"
	"github.com/go-redis/redis/v8"
	"log"
)

var ctx = context.Background()

func RedisInit() {
	global.RDB = redis.NewClient(&redis.Options{
		Addr:     "localhost:6379",
		Password: "", // no password set
		DB:       0,  // use default DB
	})

	err := global.RDB.Set(ctx, "key", "value", 0).Err()
	if err != nil {
		panic(err)
	}
	log.Println("redis连接成功")
}
